package com.x.erp.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.x.erp.dao.ImageTypeDao;
import com.x.erp.model.ImageType;
import com.x.erp.rpc.ImageTypeRpcService;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 图片场景服务
 */
@Component
@Service(interfaceName = "com.x.erp.rpc.ImageTypeRpcService", timeout = 60000)
public class ImageTypeService extends BaseService implements ImageTypeRpcService {

	@Autowired
	private ImageTypeDao ImageTypeDao;//图片场景信息DAO

	/**
	 * 查询图片场景列表
	 * @param imageType
	 * @return
	 */
	@Override
	public List<ImageType> selectImageTypeList(ImageType imageType){
		try {
			return ImageTypeDao.selectImageTypeList(imageType);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 查询图片场景数量
	 * @param imageType
	 * @return
	 */
	@Override
	public int selectImageTypeNum(ImageType imageType){
		try {
			return ImageTypeDao.selectImageTypeNum(imageType);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 新增图片场景信息
	 * @param imageType
	 * @return
	 */
	@Override
	public ImageType insertImageType(ImageType imageType){
		try {
			return this.insert(imageType);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

	/**
	 * 修改图片场景信息
	 * @param imageType
	 * @return
	 */
	@Override
	public int updateImageType(ImageType imageType){
		try {
			return this.update(imageType);
		} catch (Exception e) {
			throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
		}
	}

}
